<?php

namespace app\admin\validate;

class DeviceValidate extends BaseValidate
{
    protected $rule = [
        'id' => 'require|integer',
        'type' => 'require|in:weather,frozen,buried_frozen',
        'title' => 'require|max:200',
        'description' => 'max:200',
        'serial_number' => 'require|max:32|unique:device',
        'longitude' => 'float',
        'latitude' => 'float',
        'address' => 'max:200',
        'status' => 'require|in:enable,disable',
    ];

    protected $message = [
        'id.require' => 'id不能为空',
        'id.integer' => 'id必须是整数',
        'type.require' => 'type不能为空',
        'type.in' => 'type必须是weather,frozen,buried_frozen',
        'title.require' => 'title不能为空',
        'title.max' => 'title长度不能超过200',
        'description.max' => 'description长度不能超过200',
        'serial_number.require' => 'serial_number不能为空',
        'serial_number.max' => 'serial_number长度不能超过32',
        'serial_number.unique' => 'serial_number重复',
        'longitude.float' => 'longitude必须是浮点数',
        'latitude.float' => 'latitude必须是浮点数',
        'address.max' => 'address长度不能超过200',
        'status.require' => 'status不能为空',
        'status.in' => 'status必须是enable,disable',
    ];

    protected $scene = [
        'create' => ['type', 'title', 'description', 'serial_number', 'longitude', 'latitude', 'address', 'status'],
        'update' => ['id', 'type', 'title', 'description', 'serial_number', 'longitude', 'latitude', 'address', 'status'],
    ];
}